import { createApp } from 'vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import App from './App.vue'
import router from './router'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from "axios";

import { createPinia } from 'pinia'


import piniaPersistedState from "pinia-plugin-persistedstate"
const pinia = createPinia()
pinia.use(piniaPersistedState);

const app = createApp(App)


// 是否在启动时生成生产提示
app.config.productionTip = false
//将axios进行全局设置
app.config.globalProperties.$axios = axios
// 指定 axios 的全局配置，指定为后端服务器地址
axios.defaults.baseURL = 'http://localhost:8080/'
//指定axios的请求头中携带cookie
axios.defaults.withCredentials = true;


// // 请求拦截器
// axios.interceptors.request.use(config => {
//     // 登录接口不携带 token
//     if (!config.url.startsWith('/user')) {
//         const token = localStorage.getItem('token')
//         if (token) {
//             // 请求体  body   Header 请求头（放置数据{一般不是自定义  token}）
//             config.headers['authorization'] = `Bearer ${token}`
//         }
//     }
//     return config
// }, error => {
//     return Promise.reject(error)
// })



app.use(pinia)
app.use(router)
app.use(ElementPlus)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.mount('#app')

